package com.cn.mybatis.zy.zymybatis.controller;

import com.cn.mybatis.zy.zymybatis.entity.User;
import com.cn.mybatis.zy.zymybatis.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhangyi
 * @date 2018/12/18 11:42
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/info")
    public String info(Model model){
        List<User> allUsers = userService.getAllUsers();
        model.addAttribute("user",allUsers);
        allUsers.stream().forEach(a -> {
            System.out.println(a);
        });
        return "index";
    }
}
